#include <bits/stdc++.h>

using namespace std;

ifstream fin("detect.in");
ofstream fout("detect.out");

const int N = 100005;

int t, n, m, L, V, d[N], v[N], a[N], p[N];
vector<pair<int, int>> s;

int ceil_div(int n, int m)
{
    return (n + m - 1) / m;
}

int main()
{
    fin >> t;
    while (t--)
    {
        fin >> n >> m >> L >> V;
        for (int i = 0; i < n; fin >> d[i] >> v[i] >> a[i++]);
        for (int i = 0; i < m; fin >> p[i++]);

        for (int i = 0; i < n; i++)
        {
            if (v[i] <= V && a[i] <= 0) continue;
            if (v[i] <= V)
            {
                int e = upper_bound(p, p + m, d[i] + (V * V - v[i] * v[i]) / (a[i] << 1)) - p;
                if (e == m) continue;
                s.push_back({e, m - 1});
            }
            else
            {
                int l = lower_bound(p, p + m, d[i]) - p;
                if (l == m) continue;
                if (a[i] < 0)
                {
                    int e = lower_bound(p, p + m, d[i] + ceil_div(v[i] * v[i] - V * V, -a[i] << 1)) - p - 1;
                    if (l > e) continue;
                    s.push_back({l, e});
                }
                else s.push_back({l, m - 1});
            }
        }

        fout << s.size() << ' ', sort(s.begin(), s.end());

        int ans = !!s.size();
        for (int i = 1; i < s.size(); i++)
        {
            if (s[i].first > s[i - 1].second) ans++;
            else s[i].second = min(s[i].second, s[i - 1].second);
        }

        fout << m - ans << '\n', s.clear();
    }

    return 0;
}